home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / ifs.lha / ifs.code / text0000.txt < prev   
Encoding:
Text File  |  1989-10-24  |  22.8 KB  |  836 lines

  1. >From ahg@k.cc.purdue.edu Sun Jan 24 14:54:21 1988
  2. Path: leah!itsgw!nysernic!rutgers!princeton!udel!gatech!purdue!i.cc.purdue.edu!j.cc.purdue.edu!k.cc.purdue.edu!ahg
  3. From: ahg@k.cc.purdue.edu (Allen Braunsdorf)
  4. Newsgroups: comp.graphics
  5. Subject: (Source and test data for) IFS Explorer 1.0
  6. Keywords: by popular demand  fascinating pictures  new toys
  7. Message-ID: <2353@k.cc.purdue.edu>
  8. Date: 24 Jan 88 19:54:21 GMT
  9. Organization: 3-D Computer Graphics From Hell
  10. Lines: 822
  11.  
  12.  
  13. Since my posting, I have received about fifty requests for the source to
  14. my program.  I also received a few notes from people looking for compression
  15. software.  Unfortunately, I do not yet have such a program done.
  16.  
  17. Below is the source to the latest version of my decompression program.  It
  18. is a wonderful way to try out transforms just to see what they do.  It's a
  19. little rough, and the documentation is a hack job, but I am sure many of you
  20. will find it interesting or useful.
  21.  
  22. Also included are the data files from the Byte article (normalized to work in
  23. my system) and a few of my own.  I can post information on how to make your
  24. own data files if there is a demand.
  25.  
  26. If any of you make some neat ones, be sure to post them or send them to me!
  27.  
  28. #    This is a shell archive.
  29. #    Remove everything above and including the cut line.
  30. #    Then run the rest of the file through sh.
  31. #----cut here-----cut here-----cut here-----cut here----#
  32. #!/bin/sh
  33. # shar:    Shell Archiver
  34. #    Run the following text with /bin/sh to create:
  35. #    README
  36. #    Makefile
  37. #    dev.h
  38. #    ifs.h
  39. #    rnd.h
  40. #    ifs.c
  41. #    a.ifs
  42. #    archimedes.ifs
  43. #    box.ifs
  44. #    boxes.ifs
  45. #    circle.ifs
  46. #    cross.ifs
  47. #    dragon.ifs
  48. #    fern.ifs
  49. #    ring.ifs
  50. #    sierpinski.ifs
  51. #    square.ifs
  52. #    star.ifs
  53. #    tree.ifs
  54. #    triangle.ifs
  55. # This archive created: Sun Jan 24 14:45:24 1988
  56. # By:    Allen Braunsdorf (3-D Computer Graphics From Hell)
  57. echo shar: extracting README '(6933 characters)'
  58. cat << \SHAR_EOF > README
  59. IFS Explorer 1.0    (C)1988 by Allen Braunsdorf (ahg@k.cc.purdue.edu)
  60.  
  61. This program and its documentation may be freely copied and distributed for
  62. nonprofit uses.
  63.  
  64.  
  65. I. Introduction
  66.  
  67.     This program decodes iterated function systems (IFSs) into pictures
  68. by using the UNIX(trademark of AT&T Bell Laboratories) device independent plot
  69. libraries.  It is designed to be simple to install and use, yet be powerful
  70. and interesting enough introduce the user to this fascinating new branch of
  71. mathematics.
  72.  
  73. II. Installation
  74.  
  75.     If you do not have the plot library available, you will need to
  76. rewrite the graphic parts of the program.  If this can be done gracefully
  77. (ie: without disturbing a large portion of the code), I would be interested in
  78. your patches, as they would likely be of use to many people.
  79.  
  80.     If you do have the plot library, look through the include file
  81. dev.h for your output device, or one similar.  If you don't find it, either
  82. make up a definition and add it to dev.h, or set "DEV = GENERIC" in the
  83. Makefile.  If you do find it (or decide to roll your own), place the
  84. appropriate name on the "DEV = " line of the Makefile.
  85.  
  86.     To make your own device definition, set as many of these as you know:
  87.  
  88. XMIN, YMIN        Left, bottom pixel
  89. XMAX, YMAX        Right, top pixel
  90.  
  91.             These are usually unimportant to the program if you
  92.         are using the plot library.  Specification of these is mainly
  93.         a convenience.  XRES or YRES will be derived from these if
  94.         they are given.
  95.             The default values of these parameters are 0, 2047,
  96.         0, and 2047.  This will make XRES = YRES = 2048.
  97.  
  98. XRES, YRES        Number of dots across, down on the device
  99.  
  100.             These are used by the program for scaling.  If a value
  101.         too large is chosen, the image will appear more slowly.  If a
  102.         value too small is chosen, the image will be grainy.
  103.             If XMIN and XMAX are set, XRES will be set
  104.         automatically to match their values.
  105.             The default values of these parameters are 2048 and
  106.         2048.  This should be large enough for most output devices.
  107.  
  108. XASP, YASP        How square the device is
  109. NTSC            Is the device shaped like a TV?
  110.  
  111.             These parameters are real numbers.  They are a measure
  112.         of how wide and tall the output area is.  If the graphics
  113.         screen on your terminal were 10.5" by 8", you could define
  114.         XASP as 10.5 and YASP as 8.0.
  115.             If XFAC and YFAC are set, these values will be set to
  116.         match.
  117.             The default values for these parameters are 1.0 and
  118.         1.0 unless NTSC is defined.  Then they are set to 4.0 and
  119.         3.0 (or something equivalent).  This mimics a television's
  120.         dimensions and is useful for personal computers.
  121.  
  122. XFAC, YFAC        How square a pixel is
  123.  
  124.             These tell how wide and tall a pixel is.  If your
  125.         pixels are taller than they are wide, and you don't set these
  126.         right, everything will appear stretched on your screen.  If
  127.         you don't know what these are, just measure XASP and YASP
  128.         properly.
  129.             If XASP, YASP, XRES, and YRES are set, these values
  130.         are derived.
  131.             The default values for these parameters are 1.0 and
  132.         1.0.
  133.  
  134. ONO            Don't offset my screen!
  135.  
  136.             IFS Explorer works on a square screen.  If your
  137.         device isn't square, it will only use a part of it.  If ONO
  138.         is not defined, this region should be centered.  If this
  139.         isn't what you want [or it doesn't work!] define ONO.
  140.  
  141.     All of these parameters are set in the order that they are listed
  142. above.  In other words, XRES is set by the time XFAC is decided on whether
  143. you did it or not.
  144.     All of this magic happens in ifs.h.  Look there for more details.
  145.  
  146.     Next, put the name or link option for your plot library on the
  147. "LIB = " line.  This might look something like "LIB = -l4014" for a Tektronix
  148. 4014 terminal, or "LIB = -lex1000" for an Epson EX-1000 dot matrix printer.
  149.  
  150.     Next make sure RND is defined properly.  See rnd.h for details.  Add
  151. the proper definitions in rnd.h and Makefile.
  152.  
  153.     Finally, just type "make" and the program should compile.
  154.  
  155. III. Format of input files
  156.  
  157.     The files used by this program are similar to the data sets shown in
  158. Barnsley, M. F. and Sloan, A. D. "A Better Way to Compress Images."
  159. Byte, January 1988, pp. 215-223.
  160.  
  161.     Each file consists of one or more transforms.  Each transform has
  162. seven parameters, referred to as a, b, c, d, e, f, and p.  These should
  163. be separated by white space, but are otherwise free format.  The file
  164. should have one transform per line, and no blank lines.  After the
  165. transforms, there is an additional line containing four numbers describing
  166. the scale and origin of the image.  Every point in the image has its x
  167. coordinate multiplied by the first of these and added to the third before
  168. being scaled to the device and plotted.  Every point in the image has its y
  169. coordinate multiplied by the second of these and added to the fourth before
  170. being scaled to the device and plotted.  These can be used to zoom in on
  171. a particular part of an image for closer examination.  These can also be
  172. used if the image turns out upside down (YMIN and YMAX should be adjusted
  173. first however).
  174.     NOTE: The normalizing origin and scale parameters in the data file
  175. (those given on the last line) are NOT in device coordinates.  The virtual
  176. screen used by this program has (0, 0) at the lower left and (1, 1) at the
  177. upper right.  The origin is described in these terms.
  178.     Also, the sum of all the p parameters (the last column) must be 1.0,
  179. or you will get an error.
  180.  
  181. IV.  Running
  182.  
  183.     IFS Explorer has one argument, the name of a data file to be plotted.
  184. If this is left out, you'll get a "Usage" message.  Several example files are
  185. included with the program.  Although all my data files have names that end
  186. with ".ifs", that suffix is not necessary (ie: your file could just be called
  187. "widget").
  188.  
  189.     The Explorer also has two options.  "-n" followed by a number tells
  190. it how many points to plot (defaults to XRES*YRES).  "-o" followed by a number
  191. tells it how many points to skip before it starts plotting points (defaults to
  192. ten).
  193.  
  194. V. Future enhancements
  195.  
  196.     This program is still in its infancy, and it doesn't yet do everything
  197. I want it to.  Here are a few things I hope to add soon (and to the Amiga
  198. version):
  199.  
  200.     Autoprobability    If you don't know what to put for the last column,
  201.             the program will generate something for you.
  202.  
  203.     Autoscaling    If you don't know what to put for the last line,
  204.             the program will find out for you.
  205.  
  206.     Autostop    Will stop when the picture is done.  (Boy, this would
  207.             be nice!)
  208.  
  209.     Color        Either with several bit planes, or some other trick.
  210.  
  211.     Multiple files    Would plot several systems on the screen at once.
  212.  
  213.     Different input file formats are also being considered.
  214.  
  215.     If anyone has any suggestions, comments, questions, or bug reports
  216. about this program, please send them to me.
  217.     Additionally, I am beginning work on an IFS compression program.
  218. It is unlikely to be done any time soon.  Any additional information on
  219. this subject would be greatly appreciated.
  220.  
  221.     I hope you enjoy this program.  It has been a real eye-opener for me.
  222.  
  223.  
  224. SHAR_EOF
  225. if test 6933 -ne "`wc -c README`"
  226. then
  227. echo shar: error transmitting README '(should have been 6933 characters)'
  228. fi
  229. echo shar: extracting Makefile '(453 characters)'
  230. cat << \SHAR_EOF > Makefile
  231. #
  232. # IFS Explorer 1.0    (C)1988 by Allen Braunsdorf (ahg@k.cc.purdue.edu)
  233. #
  234.  
  235. #
  236. # Makefile    Change this rather than the other files, if possible.
  237. #
  238. # Choose a DEV (and its associated LIB) from dev.h.  Fill those in below.
  239. # Define a random number generator in rnd.h and note it below.
  240. #
  241.  
  242. DEV = GENERIC
  243. LIB = -l4014
  244. RND = RANDOM
  245.  
  246. CFLAGS = -s -O -D$(DEV) -D$(RND)
  247.  
  248. all: ifs
  249.  
  250. ifs: ifs.o
  251.     cc -o ifs ifs.o $(LIB)
  252.  
  253. ifs.o: ifs.c ifs.h dev.h rnd.h
  254.  
  255. new:
  256.     rm *.o ifs
  257. SHAR_EOF
  258. if test 453 -ne "`wc -c Makefile`"
  259. then
  260. echo shar: error transmitting Makefile '(should have been 453 characters)'
  261. fi
  262. echo shar: extracting dev.h '(915 characters)'
  263. cat << \SHAR_EOF > dev.h
  264. /*
  265.  * IFS Explorer 1.0    (C)1988 by Allen Braunsdorf (ahg@k.cc.purdue.edu)
  266.  *
  267.  */
  268.  
  269. /*
  270.  * dev.h    Device list for IFS Explorer 1.0
  271.  *
  272.  * Please add your favorite output device to the list below, or correct any
  273.  * mistakes you believe exist herein.  Mail me the product.
  274.  *
  275.  * For details on these parameters, read the documentation.
  276.  *
  277.  */
  278.  
  279. /* Generic settings */
  280.  
  281. /* Use this if you don't want to recompile when you change output devices */
  282. #ifdef GENERIC
  283. #define ONO
  284. #endif
  285.  
  286. /* Amiga terminal program (has bugs apparently!) */
  287.  
  288. #ifdef DBWTEK    /* -l4014 */
  289. #define XRES    1028
  290. #define YRES    780
  291. #define XFAC    1.0
  292. #define YFAC    1.0
  293. #define ONO
  294. #endif
  295.  
  296. /* Visual 550 terminal */
  297.  
  298. #ifdef V550    /* -l4014 */
  299. #define XRES    1028
  300. #define YRES    780
  301. #define XFAC    1.0
  302. #define YFAC    1.0
  303. #define ONO
  304. #endif
  305.  
  306. /* Epson EX-1000 printer */
  307.  
  308. #ifdef EX1000    /* -lex1000 */
  309. #define XRES    864
  310. #define YRES    648
  311. #define    XFAC    1.0
  312. #define    YFAC    1.0
  313. #endif
  314. SHAR_EOF
  315. if test 915 -ne "`wc -c dev.h`"
  316. then
  317. echo shar: error transmitting dev.h '(should have been 915 characters)'
  318. fi
  319. echo shar: extracting ifs.h '(2540 characters)'
  320. cat << \SHAR_EOF > ifs.h
  321. /*
  322.  * IFS Explorer 1.0    (C)1988 by Allen Braunsdorf (ahg@k.cc.purdue.edu)
  323.  *
  324.  */
  325.  
  326. /*
  327.  * ifs.h    Intelligent include file for IFS Explorer 1.0
  328.  *
  329.  * Constants herein:
  330.  *
  331.  *    XMIN    Minimum X coordinate on output device
  332.  *    XMAX    Maximum X coordinate on output device
  333.  *    YMIN    Minimum Y coordinate on output device
  334.  *    YMAX    Maximum Y coordinate on output device
  335.  *    XRES >= Number of pixels in X direction
  336.  *    YRES >= Number of pixels in Y direction
  337.  *    XASP    Aspect ratio in X direction of whole screen
  338.  *    YASP    Aspect ratio in Y direction of whole screen
  339.  *    XFAC    Aspect ratio in X direction of pixel
  340.  *    YFAC    Aspect ratio in Y direction of pixel
  341.  *    NTSC    Device is NTSC (like a TV or most microcomputers)
  342.  *
  343.  *     This file attempts to find reasonable values for omitted constants.
  344.  * The safest thing to do is to define XRES, YRES, XFAC, and YFAC correctly.
  345.  * The least safe (but hopefully OK) thing to do is to define NTSC if that
  346.  * condition applies (width = height * 4/3), else nothing.
  347.  *    Define things in the Makefile rather than here if possible.  Report
  348.  * any problems to the author.
  349.  *
  350.  */
  351.  
  352. #if (defined(XRES) && !defined(XMIN) && !defined(XMAX))
  353. # define XMAX    (XRES-1)
  354. # define XMIN    0
  355. #endif
  356.  
  357. #ifndef XMIN
  358. # if (defined(XRES) && defined(XMAX))
  359. #  define XMIN    ((XMAX)-(XRES-1))
  360. # else
  361. #  define XMIN    0
  362. # endif
  363. #endif
  364.  
  365. #ifndef XMAX
  366. # ifdef XRES
  367. #  define XMAX    ((XMIN)+(XRES-1))
  368. # else
  369. #  define XMAX    2047
  370. # endif
  371. #endif
  372.  
  373. #ifndef XRES
  374. # define XRES    ((XMAX)-(XMIN)+1)
  375. #endif
  376.  
  377. #if (defined(YRES) && !defined(YMIN) && !defined(YMAX))
  378. # define YMAX    (YRES-1)
  379. # define YMIN    0
  380. #endif
  381.  
  382. #ifndef YMIN
  383. # if (defined(YRES) && defined(YMAX))
  384. #  define YMIN    ((YMAX)-(YRES-1))
  385. # else
  386. #  define YMIN    0
  387. # endif
  388. #endif
  389.  
  390. #ifndef YMAX
  391. # ifdef YRES
  392. #  define YMAX    ((YMIN)+(YRES-1))
  393. # else
  394. #  define YMAX    2047
  395. # endif
  396. #endif
  397.  
  398. #ifndef YRES
  399. # define YRES    ((YMAX)-(YMIN)+1)
  400. #endif
  401.  
  402. #ifndef XASP
  403. # ifdef XFAC
  404. #  define XASP    ((XFAC)*(XRES))
  405. # else
  406. #  ifdef YASP
  407. #   define XASP    YASP
  408. #   ifdef NTSC
  409. #    undef XASP
  410. #    define XASP    (4.0*YASP/3.0)
  411. #   endif
  412. #  else
  413. #   define XASP    1.0
  414. #   ifdef NTSC
  415. #    undef XASP
  416. #    define XASP    4.0
  417. #   endif
  418. #  endif
  419. # endif
  420. #endif
  421.  
  422. #ifndef YASP
  423. # ifdef YFAC
  424. #  define YASP    ((YFAC)*(YRES))
  425. # else
  426. #  define YASP    XASP
  427. #  ifdef NTSC
  428. #   undef YASP
  429. #   define YASP    (3.0*XASP/4.0)
  430. #  endif
  431. # endif
  432. #endif
  433.  
  434. /* This is only right if ((XASP) > (YASP)), but it's fixed in main() */
  435.  
  436. #ifndef XFAC
  437. # ifndef YFAC
  438. #  define YFAC    1.0
  439. # endif
  440. # define XFAC    (((XASP)*(YRES)*(YFAC))/((YASP)*(XRES)))
  441. #else
  442. # ifndef YFAC
  443. #  define YFAC    1.0
  444. # endif
  445. #endif
  446. SHAR_EOF
  447. if test 2540 -ne "`wc -c ifs.h`"
  448. then
  449. echo shar: error transmitting ifs.h '(should have been 2540 characters)'
  450. fi
  451. echo shar: extracting rnd.h '(610 characters)'
  452. cat << \SHAR_EOF > rnd.h
  453. /*
  454.  * IFS Explorer 1.0    (C)1988 by Allen Braunsdorf (ahg@k.cc.purdue.edu)
  455.  *
  456.  */
  457.  
  458. /*
  459.  * rnd.h    How do I get a random number between 0 and 1 inclusive?
  460.  *
  461.  * Pick one of these and put it on the "RND = " line in the Makefile.
  462.  * This list is terribly incomplete, but works on every machine 'round these
  463.  * parts.  If you have an important addition, send it to me.
  464.  *
  465.  */
  466.  
  467. /* For BSD 4.3 */
  468.  
  469. #ifdef RANDOM
  470. extern long random();
  471. #define RND    (random()/2147483647.0)
  472. #endif
  473.  
  474. /* For SYS V?  At least at our house! */
  475.  
  476. #ifdef ERAND48
  477. extern double erand48();
  478. unsigned short estuff[3];
  479. #define RND    erand48(estuff)
  480. #endif
  481. SHAR_EOF
  482. if test 610 -ne "`wc -c rnd.h`"
  483. then
  484. echo shar: error transmitting rnd.h '(should have been 610 characters)'
  485. fi
  486. echo shar: extracting ifs.c '(3844 characters)'
  487. cat << \SHAR_EOF > ifs.c
  488. /*
  489.  * IFS Explorer 1.0    (C)1988 by Allen Braunsdorf (ahg@k.cc.purdue.edu)
  490.  *
  491.  * All rights reserved worldwide.  This program may be freely copied and
  492.  * distributed for nonprofit uses.  Any commercial use without express
  493.  * permission of the author is forbidden, as is removing this notice.
  494.  *
  495.  */
  496.  
  497. /*
  498.  * ifs.c    IFS Decoder by Allen Braunsdorf
  499.  *         based on information found in Byte 1988/01 pp. 215-223
  500.  *
  501.  * Throughout:
  502.  *    m    Number of transforms
  503.  *    n    Number of iterations
  504.  *    o    Number of initial points omitted from plot
  505.  *    a-f    IFS matrix coefficients
  506.  *    p[n]    Probability of point being in transform n
  507.  */
  508.  
  509. #include <stdio.h>
  510.  
  511. #include "dev.h"
  512. #include "ifs.h"
  513. #include "rnd.h"
  514.  
  515. #define MAXLINE 80
  516.  
  517. int
  518. main(argc, argv)
  519. int argc;
  520. char **argv;
  521. {
  522.     extern char *calloc();
  523.     extern double atof();
  524.     extern void exit();
  525.     void plot();
  526.  
  527.     char sbW[MAXLINE];
  528.     FILE *in;
  529.     float *a, *b, *c, *d, *e, *f, *p;
  530.     float xs, ys, xt, yt;
  531.     float pt = 0.0, pk, x = 0.0, y = 0.0, newx, newy, XFac, YFac, xo, yo;
  532.     int o = 10, i, k, m = -1, n = XRES*YRES, arg = 1;
  533.  
  534.     /* Print version number */
  535.  
  536.     fprintf(stderr, "IFS Explorer 1.0 by Allen Braunsdorf\n");
  537.  
  538.     /* Correction for tall screens */
  539.  
  540.     XFac = XFAC;
  541.     YFac = YFAC;
  542.     if ((XASP) > (YASP)) {
  543.         XFac /= YFac;
  544.         YFac /= YFac;
  545.         xo = (XRES*XFac-YRES*YFac)/(2.0*XFac);
  546.         yo = 0.0;
  547.     } else {
  548.         XFac /= XFac;
  549.         YFac /= XFac;
  550.         xo = 0.0;
  551.         yo = (YRES*YFac-XRES*XFac)/(2.0*YFac);
  552.     }
  553. #ifdef ONO    /* No offset */
  554.     xo = 0.0;
  555.     yo = 0.0;
  556. #endif
  557.  
  558.     if (2 > argc) {
  559.         fprintf(stderr, "Usage: %s -n points -o omitted IFSfile\n",
  560.             argv[0]);
  561.         exit(-1);
  562.     }
  563.     while (arg < (argc-1)) {
  564.         if ('-' == argv[arg][0]) {
  565.             switch (argv[arg][1]) {
  566.             case 'n':
  567.                 n = atoi(argv[++arg]);
  568.                 break;
  569.             case 'o':
  570.                 o = atoi(argv[++arg]);
  571.                 break;
  572.             default:
  573.                 fprintf(stderr, "Error: bad option \'%s\'\n",
  574.                     argv[arg]);
  575.                 exit(-1);
  576.             }
  577.             ++arg;
  578.         } else {
  579.             fprintf(stderr, "Error: one file only (for now)\n");
  580.             exit(-1);
  581.         }
  582.     }
  583.     n += o;
  584.     fprintf(stderr, "Iterations: %d\n", n);
  585.     fprintf(stderr, "Omitting: %d\n", o);
  586.  
  587.     if (NULL == (in = fopen(argv[arg], "r"))) {
  588.         fprintf(stderr, "Error: can't open input file\n");
  589.         exit(-1);
  590.     }
  591.     while (fgets(sbW, MAXLINE, in)) {
  592.         ++m;
  593.     }
  594.     fclose(in);
  595.  
  596.     if (-1 == m) {
  597.         fprintf(stderr, "Error: input file empty?!\n");
  598.         exit(-1);
  599.     }
  600.     if (0 == m) {
  601.         fprintf(stderr, "Error: input file invalid\n");
  602.         exit(-1);
  603.     }
  604.     a = (float *)calloc((unsigned)m, sizeof(float));
  605.     b = (float *)calloc((unsigned)m, sizeof(float));
  606.     c = (float *)calloc((unsigned)m, sizeof(float));
  607.     d = (float *)calloc((unsigned)m, sizeof(float));
  608.     e = (float *)calloc((unsigned)m, sizeof(float));
  609.     f = (float *)calloc((unsigned)m, sizeof(float));
  610.     p = (float *)calloc((unsigned)m, sizeof(float));
  611.  
  612.     if (NULL == (in = fopen(argv[arg], "r"))) {
  613.         fprintf(stderr, "Error: can't open input file\n");
  614.         exit(-1);
  615.     }
  616.     fprintf(stderr, "Transforms: %d\n", m);
  617.     for (i = 0; i < m; ++i) {
  618.         fscanf(in, "%f %f %f %f %f %f %f", a+i, b+i, c+i, d+i,
  619.             e+i, f+i, p+i);
  620.         fprintf(stderr, "\t%f %f %f %f %f %f %f\n", a[i], b[i], c[i],
  621.             d[i], e[i], f[i], p[i]);
  622.         pt += p[i];
  623.         p[i] = pt;
  624.     }
  625.     fscanf(in, "%f %f %f %f", &xs, &ys, &xt, &yt);
  626.     fprintf(stderr, "Transforming by: %f %f %f %f\n", xs, ys, xt, yt);
  627.     if ((0.01 < pt-1.0) || (0.01 < 1.0-pt)) {
  628.         fprintf(stderr, "Error: nonunity probability: %f\n", pt);
  629.         exit(-1);
  630.     }
  631.     fclose(in);
  632.  
  633.     space(XMIN, YMIN, XMAX, YMAX);
  634.     openpl();
  635.     erase();
  636.     while (n--) {
  637.         pk = RND;
  638.         for (i = 0; i < m; ++i) {
  639.             if (pk <= p[i]) {
  640.                 k = i;
  641.                 break;
  642.             }
  643.         }
  644.         newx = a[k]*x+b[k]*y+e[k];
  645.         newy = c[k]*x+d[k]*y+f[k];
  646.         x = newx;
  647.         y = newy;
  648.         if (o) {
  649.             --o;
  650.         } else {
  651.             plot((int)((x*xs*XFAC+xt)*(XRES-1)+xo)+XMIN,
  652.                 (int)((y*ys*YFAC+yt)*(YRES-1)+yo)+YMIN);
  653.         }
  654.     }
  655.     closepl();
  656. }
  657.  
  658. void
  659. plot(x, y)
  660. int x, y;
  661. {
  662.     if ((XMIN <= x) && (YMIN <= y) && (XMAX >= x) && (YMAX >= y)) {
  663.         point(x, y);
  664.     }
  665. }
  666. SHAR_EOF
  667. if test 3844 -ne "`wc -c ifs.c`"
  668. then
  669. echo shar: error transmitting ifs.c '(should have been 3844 characters)'
  670. fi
  671. echo shar: extracting a.ifs '(126 characters)'
  672. cat << \SHAR_EOF > a.ifs
  673. 0.50    0.00    1.00    0.00    0.00    0.00    0.33
  674. 0.50    0.00    -1.00    0.00    0.50    1.00    0.33
  675. 0.50    0.00    0.00    0.00    0.25    0.50    0.34
  676. 1.00    1.00    0.00    0.00
  677. SHAR_EOF
  678. if test 126 -ne "`wc -c a.ifs`"
  679. then
  680. echo shar: error transmitting a.ifs '(should have been 126 characters)'
  681. fi
  682. echo shar: extracting archimedes.ifs '(102 characters)'
  683. cat << \SHAR_EOF > archimedes.ifs
  684. 0.9972772 0.0061192 -0.0061192 0.9972772 0.0 0.0 0.999
  685. 0.0    0.0    0.0    0.0    -1.0    0.0    0.001
  686. 0.5    0.5    0.5    0.5
  687. SHAR_EOF
  688. if test 102 -ne "`wc -c archimedes.ifs`"
  689. then
  690. echo shar: error transmitting archimedes.ifs '(should have been 102 characters)'
  691. fi
  692. echo shar: extracting box.ifs '(160 characters)'
  693. cat << \SHAR_EOF > box.ifs
  694. 0.50    0.50    0.00    0.00    0.00    0.00    0.25
  695. 0.50    0.50    0.00    0.00    0.00    1.00    0.25
  696. 0.00    0.00    0.50    0.50    0.00    0.00    0.25
  697. 0.00    0.00    0.50    0.50    1.00    0.00    0.25
  698. 1.00    1.00    0.00    0.00
  699. SHAR_EOF
  700. if test 160 -ne "`wc -c box.ifs`"
  701. then
  702. echo shar: error transmitting box.ifs '(should have been 160 characters)'
  703. fi
  704. echo shar: extracting boxes.ifs '(200 characters)'
  705. cat << \SHAR_EOF > boxes.ifs
  706. 0.50    0.50    0.00    0.00    0.00    0.00    0.166
  707. 0.50    0.50    0.00    0.00    0.00    1.00    0.166
  708. 0.00    0.00    0.50    0.50    0.00    0.00    0.166
  709. 0.00    0.00    0.50    0.50    1.00    0.00    0.166
  710. 0.50    0.00    0.00    0.50    0.25    0.25    0.336
  711. 1.00    1.00    0.00    0.00
  712. SHAR_EOF
  713. if test 200 -ne "`wc -c boxes.ifs`"
  714. then
  715. echo shar: error transmitting boxes.ifs '(should have been 200 characters)'
  716. fi
  717. echo shar: extracting circle.ifs '(103 characters)'
  718. cat << \SHAR_EOF > circle.ifs
  719. 0.9999811 -0.00613588 0.00613588 0.9999811    0.0    0.0    0.999
  720. 0.0    0.0    0.0    0.0    1.0    0.0    0.001
  721. 0.5    0.5    0.5    0.5
  722. SHAR_EOF
  723. if test 103 -ne "`wc -c circle.ifs`"
  724. then
  725. echo shar: error transmitting circle.ifs '(should have been 103 characters)'
  726. fi
  727. echo shar: extracting cross.ifs '(170 characters)'
  728. cat << \SHAR_EOF > cross.ifs
  729. -0.50    -0.50    0.00    0.00    0.50    0.00    0.25
  730. -0.50    -0.50    0.00    0.00    -0.50    0.00    0.25
  731. 0.00    0.00    -0.50    -0.50    0.00    0.50    0.25
  732. 0.00    0.00    -0.50    -0.50    0.00    -0.50    0.25
  733. 0.50    0.50    0.50    0.50
  734. SHAR_EOF
  735. if test 170 -ne "`wc -c cross.ifs`"
  736. then
  737. echo shar: error transmitting cross.ifs '(should have been 170 characters)'
  738. fi
  739. echo shar: extracting dragon.ifs '(81 characters)'
  740. cat << \SHAR_EOF > dragon.ifs
  741. 0.5    -0.5    0.5    0.5    1.0    0.0    0.5
  742. 0.5    -0.5    0.5    0.5    -1.0    0.0    0.5
  743. 0.1875    0.1875    0.5    0.5
  744. SHAR_EOF
  745. if test 81 -ne "`wc -c dragon.ifs`"
  746. then
  747. echo shar: error transmitting dragon.ifs '(should have been 81 characters)'
  748. fi
  749. echo shar: extracting fern.ifs '(163 characters)'
  750. cat << \SHAR_EOF > fern.ifs
  751. 0.00    0.00    0.00    0.16    0.00    0.00    0.01
  752. 0.20    -0.26    0.23    0.22    0.00    1.60    0.07
  753. -0.15    0.28    0.26    0.24    0.00    0.44    0.07
  754. 0.85    0.04    -0.04    0.85    0.00    1.60    0.85
  755. 0.10    0.10    0.50    0.00
  756. SHAR_EOF
  757. if test 163 -ne "`wc -c fern.ifs`"
  758. then
  759. echo shar: error transmitting fern.ifs '(should have been 163 characters)'
  760. fi
  761. echo shar: extracting ring.ifs '(75 characters)'
  762. cat << \SHAR_EOF > ring.ifs
  763. 0.8    0.6    -0.6    0.8    0.0    0.0    0.99
  764. 0.0    0.0    0.0    0.0    1.0    0.0    0.01
  765. 0.5    0.5    0.5    0.5
  766. SHAR_EOF
  767. if test 75 -ne "`wc -c ring.ifs`"
  768. then
  769. echo shar: error transmitting ring.ifs '(should have been 75 characters)'
  770. fi
  771. echo shar: extracting sierpinski.ifs '(125 characters)'
  772. cat << \SHAR_EOF > sierpinski.ifs
  773. 0.50    0.00    0.00    0.50    0.00    0.00    0.33
  774. 0.50    0.00    0.00    0.50    1.00    0.00    0.33
  775. 0.50    0.00    0.00    0.50    0.50    0.50    0.34
  776. 0.50    1.00    0.00    0.00
  777. SHAR_EOF
  778. if test 125 -ne "`wc -c sierpinski.ifs`"
  779. then
  780. echo shar: error transmitting sierpinski.ifs '(should have been 125 characters)'
  781. fi
  782. echo shar: extracting square.ifs '(160 characters)'
  783. cat << \SHAR_EOF > square.ifs
  784. 0.50    0.00    0.00    0.50    0.00    0.00    0.25
  785. 0.50    0.00    0.00    0.50    0.50    0.00    0.25
  786. 0.50    0.00    0.00    0.50    0.00    0.50    0.25
  787. 0.50    0.00    0.00    0.50    0.50    0.50    0.25
  788. 1.00    1.00    0.00    0.00
  789. SHAR_EOF
  790. if test 160 -ne "`wc -c square.ifs`"
  791. then
  792. echo shar: error transmitting square.ifs '(should have been 160 characters)'
  793. fi
  794. echo shar: extracting star.ifs '(143 characters)'
  795. cat << \SHAR_EOF > star.ifs
  796. 0.3090169 -0.9510565 0.9510565 0.3090169 0.0    0.0    0.85
  797. -0.999    0.0    0.0    0.0    0.0    0.3249196    0.10
  798. 0.0    0.0    0.0    0.0    1.0    0.3249196    0.05
  799. 0.5    0.5    0.5    0.5
  800. SHAR_EOF
  801. if test 143 -ne "`wc -c star.ifs`"
  802. then
  803. echo shar: error transmitting star.ifs '(should have been 143 characters)'
  804. fi
  805. echo shar: extracting tree.ifs '(162 characters)'
  806. cat << \SHAR_EOF > tree.ifs
  807. 0.00    0.00    0.00    0.50    0.00    0.00    0.05
  808. 0.10    0.00    0.00    0.10    0.00    0.20    0.15
  809. 0.42    -0.42    0.42    0.42    0.00    0.20    0.40
  810. 0.42    0.42    -0.42    0.42    0.00    0.20    0.40
  811. 2.00    2.00    0.50    0.00
  812. SHAR_EOF
  813. if test 162 -ne "`wc -c tree.ifs`"
  814. then
  815. echo shar: error transmitting tree.ifs '(should have been 162 characters)'
  816. fi
  817. echo shar: extracting triangle.ifs '(103 characters)'
  818. cat << \SHAR_EOF > triangle.ifs
  819. -1.0    0.0    0.0    0.0    1.0    0.0    0.34
  820. 0.5    0.0    0.866    0.0    0.0    0.0    0.33
  821. 0.5    0.0    -0.866    0.0    0.5    0.866    0.33
  822. 1    1    0    0
  823. SHAR_EOF
  824. if test 103 -ne "`wc -c triangle.ifs`"
  825. then
  826. echo shar: error transmitting triangle.ifs '(should have been 103 characters)'
  827. fi
  828. #    End of shell archive
  829. exit 0
  830.  
  831. Allen Braunsdorf            WORK    k.cc.purdue.edu!ahg
  832. General Consultant            SCHOOL    ei.ecn.purdue.edu!braunsdo
  833. Purdue University Computing Center    HOME    ee.ecn.purdue.edu!gawk!akb
  834.  
  835.  
  836.